package com.codeforces.contest.c300;

import java.util.Scanner;

public class _300A {

	static Scanner scanner = new Scanner(System.in);
	static int N, na, nb, nc;
	static int[] num, a, b, c;

	public static void main(String[] args) {
		N = scanner.nextInt();
		num = new int[N];
		a = new int[N];
		b = new int[N];
		c = new int[N];
		na = nb = nc = 0;
		for (int i=0;i<N;++i) {
			num[i] = scanner.nextInt();
			if (num[i] > 0) {
				a[na] = num[i];
				na++;
			}
			else if (num[i] < 0) {
				b[nb] = num[i];
				nb++;
			}
			else {
				c[nc] = num[i];
				nc++;
			}
		}
		
		if (nb >= 3) {
			a[na] = b[nb-1];
			nb--;
			na++;
			a[na] = b[nb-1];
			nb--;
			na++;
		}
		
		if (nb % 2 == 0) {
			c[nc] = b[nb-1];
			nb--;
			nc++;
		}
		System.out.print(nb);
		for (int i=0;i<nb;++i) {
			System.out.print(" " + b[i]);
		}
		System.out.println();
		System.out.print(na);
		for (int i=0;i<na;++i) {
			System.out.print(" " + a[i]);
		}
		System.out.println();
		System.out.print(nc);
		for (int i=0;i<nc;++i) {
			System.out.print(" " + c[i]);
		}
		System.out.println();
	}

}
